<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of login
 *
 * @author xps
 */
class check_usuario {
    function index()
    {
        $this->CI =&get_instance();
        $controlador= strtolower($this->CI->router->class);
        $metodo=strtolower($this->CI->router->method);
        if ($this->CI->session->userdata('login')){
            $lista_blanca_controllers = array('con_login');
        }else{
            $lista_blanca_controllers = array('con_login','con_principal');
        }
        if (!in_array($controlador, $lista_blanca_controllers)){
            if ($this->CI->session->userdata('login')){
                switch ($this->CI->mod_login->valida_permiso($this->CI->session->userdata('id_tipo_usuario'),$controlador,$metodo)) {
                    case -1:
                        $this->CI->session->set_flashdata('modal_error',error_permiso);
                        redirect($controlador.'/index');
                    break;
                    case -2:
                        $this->CI->session->set_flashdata('modal_error',error_permiso);
                        redirect('con_principal/index');
                        break;
                    default:
                        break;
                }
            }else{
                $this->CI->session->set_flashdata('modal_error',no_login);
                redirect('con_principal');
            }
       }
    }
}
?>